#!/bin/sh
[ "$(uci get syncdial.config.enabled)" = "1" ] && \
	[ "$(uci get syncdial.config.old_frame)" = "1" ] && \
	[ "$DEVICE" = "$(uci get network.wan.ifname)" ] && \
	[ "$ACTION" = "ifup" ] && {
	ifname=$(uci get network.wan.ifname)
	wannum=$(uci get syncdial.config.wannum)
	for i in $(seq 1 $wannum)
	do
		[ -d /sys/class/net/macvlan$i ] || {
			ip link add link $ifname name macvlan$i type macvlan
			ifconfig macvlan$i hw ether $(echo $(cat /sys/class/net/$ifname/address|awk -F ":" '{print $1":"$2":"$3":"$4":"$5":" }')$(echo "" | awk -F ":" '{printf("%X\n", 16+i);}' i=$i))
			ifconfig macvlan$i up
		}
	done
}
